<%--
 *  File:   DataLookedHead.jsp
 *  Date	2011/5/22	  
 *  Author		  Kevinfan
 *
 *  Copyright (C) 2000 - 2011 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%
  //init param
  String privilegeCode = "A0108";
  String strModuleName = "TDR";
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/CommonHeader.inc" %>
<%@ include file="/inc/OvalLocationDefault.inc" %>

<html>
<head>
<PageFlow:CheckPageFlow pageName="p_purchaseverify"/>
<%
  Vector summary = (Vector)pageContext.getAttribute("totalsummary");
  HashMap userinfo = (HashMap)session.getAttribute("userinfo");
  Integer style1 = (Integer) pageContext.getAttribute("style");
  int endday1 = Integer.parseInt((String)pageContext.getAttribute("endday1"));
  int endday2 = Integer.parseInt((String)pageContext.getAttribute("endday1"));
  java.util.Calendar cal = java.util.Calendar.getInstance();      
  int day = cal.get(Calendar.DAY_OF_MONTH);
  String style = style1.toString();
  String  issalesman = (String) userinfo.get("issalesman");
  Integer  departmentid = (Integer) userinfo.get("deptid");
  String  username = (String) userinfo.get("empoyeename");
  String deptid = departmentid.toString();
  String flag = (String)pageContext.getAttribute("flag");
  if(summary == null)summary = new Vector();
  
%>
<%@ include file="/inc/CatchError.inc" %>
<%@ include file="/inc/SumDiv.inc" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/SummaryDivision.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/keyFunction.js"></script>
<script language="JavaScript">
function page_action(thisobj,pname)
{	
  years = document.cform.years.value;
  months = document.cform.months.value;
  businesstype = document.cform.businesstype.value;
  statusstr = document.cform.status.value;
  regionid = document.cform.regionid.value;
  businessarealist = document.cform.businessarealist.value;
  proviceofficelist = document.cform.proviceofficelist.value;
  userids = document.cform.userids.value;
  switchTags(thisobj);
  parent.down.location.href= pname+"&years="+years+"&months="+months+"&status=" +statusstr+"&regionid="+regionid+"&businessarealist="+businessarealist+"&proviceofficelist="+proviceofficelist+"&userids="+userids;
}
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  if(!editform) return;
  editform.action = "PharmacyPurchaseVerify.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}

function subDiv() {
   	document.cform.actionname.value = "savep";
  	document.cform.target = "_self";
  	isRunning = true;
  	document.cform.submit();
}

function showDiv(element) {
    var W = document.documentElement.scrollWidth;
    var H = document.documentElement.scrollHeight;
    var selfW = document.getElementById(element).style.width;
    var selfH = document.getElementById(element).style.height;
    document.getElementById(element).style.left = (W - parseInt(selfW)) / 2 + 'px';
    document.getElementById(element).style.top = (H - parseInt(selfH)) / 2 + 'px';
    document.getElementById(element).style.display = 'block';
    var mDiv = document.getElementById("mDiv");
    mDiv.style.display = '';
    document.cform.subbutton.focus();
}

function hidDiv(element) {
    document.getElementById(element).style.display = 'none';
    document.getElementById("mDiv").style.display = 'none';
}

function clickRow(obj,idx)
{
  var cform = document.cform;
  cform.purchasemonthdata_id.value = eval('obj.all.purchasemonthdataid'+idx).value;
  cform.orgid.value = eval('obj.all.orgid'+idx).value;
  cform.partnerid.value = eval('obj.all.partnerid'+idx).value;
  cform.prodid.value = eval('obj.all.prodid'+idx).value;
  cform.year.value = eval('obj.all.year'+idx).value;
  cform.month.value = eval('obj.all.month'+idx).value;
  cform.re_mark.value = eval('obj.all.remark'+idx).value;
}

function page_allcheckselect(){
	var allcheck = cform.allcheck.checked;
	var alldatafile = document.getElementsByName('deleteids');
	var length = alldatafile.length;
	if(allcheck){
		for(var i = 1 ; i <= length;i++){
			alldatafile[i-1].checked = true;
		}
	}else{
		for(var i = 1 ; i <= length;i++){
			alldatafile[i-1].checked = false;
		}	
	}
}

function page_pass(){
  if(isNullChecked(cform.deleteids)) 
  {
    alert('<%=message.getMessageDesc("PLEASE_SELECT")%>');
    return;
  }
  for(var i=0;i<cform.deleteids.length;i++){
	var n = i + 1;
	if(cform.deleteids[i].checked){
		if(eval('cform.folwqty'+n).value == "" || eval('cform.notfolwqty'+n).value == "" || eval('cform.qty'+n).value == ""){alert('<%=message.getMessageDesc("Verify_Pass")%>');return;}
	}
  }
  cform.changestatus.value = 41;
  cform.actionname.value = "approve"; 
  cform.target = "_self";
  isRunning = true;
  document.cform.submit();
}

function page_noPass(){
	if(isNullChecked(cform.deleteids)) 
  {
    alert('<%=message.getMessageDesc("PLEASE_SELECT")%>');
    return;
  }
  for(var i=0;i<cform.deleteids.length;i++){
	var n = i + 1;
	if(cform.deleteids[i].checked){
		if(eval('cform.folwqty'+n).value == "" || eval('cform.notfolwqty'+n).value == "" || eval('cform.qty'+n).value == ""){alert('<%=message.getMessageDesc("Verify_Pass")%>');return;}
	}
  }
  cform.changestatus.value = 28;
  cform.actionname.value = "approve";
  cform.target = "_self";
  isRunning = true;
  document.cform.submit();
}

function page_reTypeIn(){
	if(isNullChecked(cform.deleteids)) 
  {
    alert('<%=message.getMessageDesc("PLEASE_SELECT")%>');
    return;
  }
	 for(var i=0;i<cform.deleteids.length;i++){
		var n = i + 1;
		if(cform.deleteids[i].checked){
			if(eval('cform.status'+n).value != "28"){alert('<%=label.getLabelName("L_PleseNoPass") %>');return;}
		}
	}
  cform.actionname.value = "retypeinp";
  cform.target = "_self";
  isRunning = true;
  document.cform.submit();
}

function page_salesDetail()
{
    orgid = cform.orgid.value;
    partnerid =cform.partnerid.value;
 	if(isEmpty(orgid)) 
	  {
	    alert('<%=message.getMessageDesc("PLEASE_SELECT")%>');
	    return;
	  }
    productid = cform.prodid.value;
    year = cform.year.value;
    month = cform.month.value;
    businesstype = cform.businesstype.value;
	<%if(!"Y".equals(issalesman)){%>
    regionid = cform.regionid.value;
    userids = cform.userids.value;
	proviceofficecode = document.cform.proviceofficelist.value;
	businessareacode = document.cform.businessarealist.value;
	popup('<%=contextPath %>/tdr/dataverify/SalesDetail.jsp?<%= OvalTools.randomURL() %>&businesstype='+businesstype+'&orgid='+orgid+'&partnerid='+partnerid+'&productid='+productid+'&year='+year+'&month='+month +'&userids='+userids + '&proviceofficecode='+proviceofficecode + '&businessareacode='+businessareacode+'&regionid='+regionid,'newwindow','height=500, width=900,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no');
	<%}else{%>
	popup('<%=contextPath %>/tdr/dataverify/SalesDetail.jsp?<%= OvalTools.randomURL() %>&businesstype='+businesstype+'&orgid='+orgid+'&partnerid='+partnerid+'&productid='+productid+'&year='+year+'&month='+month,'newwindow','height=500, width=900,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no');
	<%}%>
}

function page_purchaseDetail()
{
    <% if("1".equals(style)){ %>    
    orgid = cform.orgid.value;
    partnerid =cform.partnerid.value;	
    <%}else{%>
    orgid = cform.partnerid.value;
    partnerid =cform.orgid.value;
    <%}%>
    if(isEmpty(orgid)) 
	  {
	    alert('<%=message.getMessageDesc("PLEASE_SELECT")%>');
	    return;
	  }
    productid = cform.prodid.value;
    year = cform.year.value;
    month = cform.month.value;
    businesstype = cform.businesstype.value;
	<%if(!"Y".equals(issalesman)){%>
    regionid = cform.regionid.value;
    userids = cform.userids.value;
	proviceofficecode = document.cform.proviceofficelist.value;
	businessareacode = document.cform.businessarealist.value;
	popup('<%=contextPath %>/tdr/dataverify/PurchaseDetail.jsp?<%= OvalTools.randomURL() %>&businesstype='+businesstype+'&orgid='+orgid+'&partnerid='+partnerid+'&productid='+productid+'&year='+year+'&month='+month +'&userids='+userids + '&proviceofficecode='+proviceofficecode + '&businessareacode='+businessareacode+'&regionid='+regionid,'newwindow','height=500, width=900,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no');
	<%}else{%>
	popup('<%=contextPath %>/tdr/dataverify/PurchaseDetail.jsp?<%= OvalTools.randomURL() %>&businesstype='+businesstype+'&orgid='+orgid+'&partnerid='+partnerid+'&productid='+productid+'&year='+year+'&month='+month,'newwindow','height=500, width=900,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no');
	<%}%>
}

//salesman
function popRep() {
	var regionid=cform.regionid.value;
	var proviceofficecode = document.cform.proviceofficelist.value;
	var businessareacode = document.cform.businessarealist.value;
	var status = "height=400, width=600, top=100, left=100, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no";
	var url = "SalesPopWindow.jsp?<%= OvalTools.randomURL() %>&regionid="+regionid+"&proviceofficecode="+proviceofficecode+"&businessareacode="+businessareacode;
	popwindow = window.open(url, "newwindow", status);
  }

function SetSalesMan(id,code,name){
	cform.userids.value=id;
	cform.employeecode.value=code;
	cform.employeename.value=name;
}

//getbusinessarea
function page_getpriviceoffice(){
	var objdeptcode=eval("cform.regionid");
	var style = document.cform.style.value;
	if (objdeptcode==""){
	    return;
	}
	var  datahandler = new  DataHandler();
	datahandler.add_params("style" , style, 'Integer');
	datahandler.add_params("regionid" , objdeptcode.value , "Integer");
	datahandler.getResultFromVector("resultproviceoffice","proviceofficename","proviceofficecode","document.cform.proviceofficelist");
	datahandler.add_job("j_purchaseverify");
	datahandler.runDataHandler();
  }

function page_getbusinessarea(){
	var regionid = document.cform.regionid.value;
	var style = document.cform.style.value;
	var objdeptcode=eval("cform.proviceofficelist");
	if (objdeptcode==""){
	    return;
	}
	var  datahandler = new  DataHandler();
	datahandler.add_params("style" , style, 'Integer');
	datahandler.add_params("regionid" , regionid, "Integer");
	datahandler.add_params("proviceofficelist" , objdeptcode.value , "String");
	datahandler.getResultFromVector("resultbusinessarea","businessareaname","businessareacode","document.cform.businessarealist");
	datahandler.add_job("j_purchaseverify");
	datahandler.runDataHandler();
 }


</script>
</head>

<body>
<iframe id="reloadHandler" name="reloadHandler" style="display:none"></iframe>
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
    <input type="hidden" name="pagename" value="p_purchaseverify">
    <input type="hidden" name="actionname">
    <custom:hidden property="style"/>
    <custom:hidden property="changestatus"/>
    <custom:hidden property="businesstype"/>
    <custom:hidden property="orgid"/>
	<custom:hidden property="partnerid"/>
	<custom:hidden property="prodid"/>
<custom:hidden property="year"></custom:hidden>
<custom:hidden property="month"></custom:hidden>
    <table width="100%" cellspacing="0" border="0" cellpadding="0">
      <tr>
        <td>
          <table  width="500" border="0" cellspacing="0" >
        	<tr>
        		<%       
					String year = cal.get(Calendar.YEAR)+"";     
					String month = cal.get(Calendar.MONTH)+"";
					if(cal.get(Calendar.MONTH) == 0){
						month = "12";
						year = (cal.get(Calendar.YEAR)-1)+"";
					}  
					if("first".equals(flag)){ 
				%>
	        	<td style="width:40px;" class="td_right" ><%=label.getLabelName("L_Year1")  +  label.getLabelName("L_Colon") %></td>
	        	<td style="width:50px;" class="td_left"><custom:selectdic property="years" dictType="Years" command="notnull" value="<%=year %>" label="L_Year1"/></td>
	        	<td style="width:40px;" class="td_right"><%=label.getLabelName("L_Month") +  label.getLabelName("L_Colon") %></td>
	        	<td style="width:50px;" class="td_left"><custom:selectdic property="months" dictType="Months" command="notnull" value="<%=month %>" label="L_Month"/></td>
	        	<%}else{ %>
	        	<td style="width:40px;" class="td_right"><%=label.getLabelName("L_Year1") +  label.getLabelName("L_Colon") %></td>
	        	<td style="width:50px;" class="td_left"><custom:selectdic property="years" dictType="Years" command="notnull" label="L_Year1"/></td>
	        	<td style="width:40px;" class="td_right"><%=label.getLabelName("L_Month") +  label.getLabelName("L_Colon") %></td>
	        	<td style="width:50px;" class="td_left"><custom:selectdic property="months" dictType="Months" command="notnull" label="L_Month"/></td>
	        	    <%
	        	    }
					if("1".equals(style)){
					%>
					<td style="width:40px;" class="td_right"><%=label.getLabelName("L_Status") +  label.getLabelName("L_Colon") %></td>
	        	  <td style="width:50px;" class="td_left"><custom:selectdic property="status" dictType="ZylStatus" valueCriteria="40,28,41" defaultValue="-------" defaultValueCost="" command="notnull" label="Status"/></td>
					<% }
					else {
						if("Y".equals(issalesman)){
			        %>
	        	<td style="width:40px;" class="td_right"><%=label.getLabelName("L_Status") +  label.getLabelName("L_Colon") %></td>
	        	<td style="width:50px;" class="td_left"><custom:selectdic property="status" dictType="ZylStatus" valueCriteria="41,28" defaultValue="-------"  defaultValueCost="" command="notnull" label="Status"/></td>
        	    <%}else{ %>
        	    <td style="width:40px;" class="td_right"><%=label.getLabelName("L_Status") +  label.getLabelName("L_Colon") %></td>
	        	<td style="width:50px;" class="td_left"><custom:selectdic property="status" dictType="ZylStatus" valueCriteria="40,28,41" defaultValue="-------" defaultValueCost="" command="notnull" label="Status"/></td>
				<%} }%> 
        	    </tr>
				</tr>
				</table>
				</td></tr>
				<tr>
				<td>
				<table width="1000" border="0" cellspacing="0" >
        	      <%
	                if("Y".equals(issalesman)){
	                %> 
	                <tr>
	                <td style="width:40px;">&nbsp;</td><td style="width:150px;">&nbsp;</td>
	               <td style="width:40px;">&nbsp;</td><td style="width:150px;">&nbsp;</td>
	               <td style="width:40px;">&nbsp;</td><td style="width:150px;">&nbsp;</td>
	               <td style="width:60px;">&nbsp;</td><td style="width:150px;">&nbsp;</td>
	               <td style="width:60px;">&nbsp;</td><td style="width:150px;">&nbsp;</td>
	               </tr>
	                <%}else{ %>
        	    <tr>
        	   <td style="width:40px;" class="td_right"><%=label.getLabelName("L_Businessarea") +  label.getLabelName("L_Colon") %></td>
        	  	<td style="width:150px;" class="td_left">
        	  	<custom:select property="regionid" optionInnerTextKey="regionname" optionsName="resultregion" optionValueKey="regionid" style="width:150px;" onchange="page_getpriviceoffice()" defaultValue="ALL" defaultValueCost=""/></td>
        	    <td style="width:40px;" class="td_right"><%=label.getLabelName("L_ProvinceOffice") +  label.getLabelName("L_Colon") %></td>
				<td style="width:150px;" class="td_left">
				
				<custom:select property="proviceofficelist" optionInnerTextKey="proviceofficename" optionsName="resultproviceoffice" optionValueKey="proviceofficecode" style="width:150px;" defaultValue="----------" defaultValueCost="" onchange="page_getbusinessarea();"/></td>
				
			   <td style="width:60px;" class="td_right"><%=label.getLabelName("L_BusinessAreaName") +  label.getLabelName("L_Colon") %></td>
				<td style="width:150px;" class="td_left">
				<custom:select property="businessarealist" optionInnerTextKey="businessareaname" optionsName="resultbusinessarea" optionValueKey="businessareacode" style="width:150px;" defaultValue="----------" defaultValueCost=""/> </td>
				
        	   <td style="width:60px;" class="td_right"><%=label.getLabelName("L_BusinessContact") +  label.getLabelName("L_Colon") %></td>
				<td style="width:150px;">
			<custom:text property="employeename" size="20" readonly="true" style="border:1px #7F9DB9 solid;"/>
			<a onClick="javascript:popRep();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a> 
			<custom:hidden property="userids"/>
			<custom:hidden property="employeecode"/>
		   </td>
			<td style="10px;">&nbsp;</td>
			<%} %>
        	</tr>
          </table>
        </td>
      </tr>
      <tr>
         <td style="PADDING-BOTTOM: 0px; PADDING-LEFT: 1px; PADDING-RIGHT: 1px; PADDING-TOP: 0px">
             <table border="2" cellpadding="0" height="30px" cellspacing="0">
             <tbody>
                <tr>
					<td class="hand1" valign="bottom" style="border-left:none;border-right:none;" width="120" background="<%=contextPath %>/images/cn/manv_1_bg.png" onclick="javascript:page_action(this,'<%=contextPath%>/tdr/dataverify/Level1DealSales.jsp?<%= OvalTools.randomURL() %>&businesstype=110');"><div align="center"><%= label.getLabelName("L_OneLevelDeal")%></div></td>
                    <td class="hand1" valign="bottom" style="border-right:none;border-left:none;" width="120" background="<%=contextPath %>/images/cn/manv_1_bg.png" onclick="javascript:page_action(this,'<%=contextPath%>/tdr/dataverify/Level2DealSales.jsp?<%= OvalTools.randomURL() %>&businesstype=120');"><div align="center"><%= label.getLabelName("L_TwoLevelDeal")%></div></td>      
					<td class="hand1" valign="bottom" style="border-right:none;border-left:none;" width="120" background="<%=contextPath %>/images/cn/manv_1_bg.png" onclick="javascript:page_action(this,'<%=contextPath%>/tdr/dataverify/HospitalSales.jsp?<%= OvalTools.randomURL() %>&businesstype=150');"><div align="center"><%= label.getLabelName("L_HospitalSalese")%></div></td>
					<td class="hand1" valign="bottom" style="border-left:none;" width="120" background="<%=contextPath %>/images/cn/manv_1_bg.png" onclick="javascript:page_action(this,'<%=contextPath%>/tdr/dataverify/DoctorSales.jsp?<%= OvalTools.randomURL() %>&businesstype=170');"><div align="center"><%= label.getLabelName("L_DoctorRecipel")%></div></td>
				</tr>
                </tbody>
                </table>
           </td>
        </tr>
 </table>
 </form>
 </body>
 </html>